package com.qingcloud.df.executor.config;

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * swagger的配置
 *
 * @author wangjinnan
 */
@Configuration
@EnableOpenApi
public class SwaggerConfig {

    @Bean
    public Docket allApi() {
        return new Docket(DocumentationType.OAS_30)
                .groupName("all")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("数据融合平台运行中心相关API")
                .description("数据融合平台运行中心相关API")
                .license("MIT")
                .licenseUrl("http://opensource.org/licenses/MIT")
                .contact(new Contact("北京蛙鸣华清环保科技有限公司",
                        "http://www.waming-air.cn",
                        "customer@wamingtech.com"))
                .version("1.0.0")
                .build();
    }

}
